package com.smartleanx.module.hrm.task.job;

import com.smartleanx.framework.tenant.core.context.TenantContextHolder;
import com.smartleanx.framework.tenant.core.job.TenantJob;
import com.smartleanx.module.hrm.intergration.BpmServiceProvider;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 部署脚本重新初始化
 *
 * TODO 下次发版结束后删除此接口
 *
 * @author tengcj
 * @since 2024/6/24
 */
@Slf4j
@Component
public class BpmInitJob {

    @Resource
    private BpmServiceProvider bpmServiceProvider;

    @XxlJob("reInitBpm")
    @TenantJob
    public void reInitBpm() {
        if (TenantContextHolder.getTenantId() == 1) {
            return;
        }
        log.info("部署脚本重新初始化任务开始====================");
        bpmServiceProvider.reInitBpmModel();
        log.info("部署脚本重新初始化任务结束====================");
    }

}
